﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
namespace Me.Framework.Json.DeConvert
{
    public class ObjToJson
    {
        public virtual string ToJson<T>(T obj)
        {
            using (var ms = new MemoryStream())
            {
                new DataContractJsonSerializer(typeof(T)).WriteObject(ms,obj);
                return Encoding.UTF8.GetString(ms.ToArray());
            }
        }
    }
}
